using System.BusinessObjects.Transactions;
using Blazing.BusinessObjects.Cms;
using NHibernate;
using NHibernate.Criterion;
using System.Linq;
using System.Collections.Generic;

namespace Blazing.BusinessObjects.Queries
{
    public class QryFetchPageByUrl
    {
        public static ICriteria Query(int siteId, string url)
        {
            ICriteria qry = UnitOfWork.CurrentSession.CreateCriteria(typeof(Contentpage));
            qry.Add(Expression.Eq("Site.ID", siteId));
            qry.Add(Expression.Eq("Url", url));
            qry.AddOrder(Order.Asc("Name"));

            qry.SetCacheable(true);
            return qry;
        }

        //public static IEnumerable<Contentpage> QueryLinq(int siteId, string url)
        //{
        //    var result = from c in UnitOfWork.CurrentSession.Linq<Contentpage>()
        //                 where c.Site.ID == siteId &&
        //                       c.Url == url
        //                 orderby c.Name
        //                 select c;
        //    return result;
        //}
    }
}
